package com.xuxk.project.oauth.service.impl;

import com.github.pagehelper.Page;
import com.xuxk.project.oauth.bean.XuxkRole;
import com.xuxk.project.oauth.dao.XuxkRoleDao;
import com.xuxk.project.oauth.dto.XuxkRoleDto;
import com.xuxk.project.oauth.service.XuxkRoleService;
import com.xuxk.project.oauth.vo.XuxkRoleVo;
import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * Manager implementation for XuxkRole, responsible for business processing, and communicate between web and persistence layer.
 * @author 橙云科技有限公司
 */
@Service
public class XuxkRoleServiceImpl implements XuxkRoleService {

	@Resource
	private XuxkRoleDao xuxkRoleDao;
    @Override
	public Page<XuxkRoleVo>  listXuxkRoles(Map<String, Object> map, RowBounds rowBounds){


        Page<XuxkRoleVo> xuxkRolePage =  xuxkRoleDao.listXuxkRoles(map,rowBounds);
		return xuxkRolePage;
	}
    @Override
	public List<XuxkRole> listXuxkRoleByDto(XuxkRoleDto dto){
        /**
         * 使用例子：
		 *
         * OaEmployeeDto dto1 = new OaEmployeeDto();
         * 		dto1.createCriteria()
         * 			.andIdEqualTo(1L)
         * 			.andFnumberEqualTo("NLW17004");
         * 	xuxkRoleDao.listByDto(dto1);
         */

		return xuxkRoleDao.listByDto(dto);
	}

    @Override
	public void deleteXuxkRole(Integer id )  {
	    Map<String,Object> map = new HashMap<>();
        map.put("id",id);

		xuxkRoleDao.deleteByPrimaryKey(map);
	}

    /**
    * 全量更新
    * @return
    */
    @Override
    public Integer updateXuxkRole(XuxkRole xuxkRole)  {


        return xuxkRoleDao.updateXuxkRole(xuxkRole);
    }

    /**
    * 部分更新
	* @return
	*/
    @Override
    public Integer patchUpdateXuxkRole(XuxkRole xuxkRole)  {

        return xuxkRoleDao.patchUpdateXuxkRole(xuxkRole);

    }

    /**
    * 新增
	* @return
	*/
    @Override
    public Integer insertXuxkRole(XuxkRole xuxkRole)  {


		xuxkRoleDao.insertSelective(xuxkRole);

        return xuxkRole.getId();

    }
    @Override
    public XuxkRole getXuxkRole(Integer id ){
        Map<String,Object> map = new HashMap<>();
        map.put("id",id);

        return xuxkRoleDao.getXuxkRole(map);
    }

}